package controladores;

import java.io.Serializable;

import modelo.GestaoAplicacao;

import com.example.rm.teste.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Spinner;


public class MenuPrincipal extends Activity implements Serializable {
	public static final String estruturasLidas = "estruturasTexto";
	
	protected static GestaoAplicacao estruturasLer;
	
	final Context context = this;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_menu);
		
		estruturasLer = new GestaoAplicacao();
		
		//ga.LerUtilizadores(this);
		estruturasLer.LerUtilizadores(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu, menu);
		return true;
	}
	
	public void abreadic(View v){
		Intent intent1 = new Intent(getApplicationContext(), MainActivity.class);
		Spinner sp = (Spinner) findViewById(R.id.SpinnerSUtilizadores);
		String nome = sp.getSelectedItem().toString();
		intent1.putExtra("Utilizador",nome);
		startActivity(intent1);
	}
	
	public void abrehist(View v){
		Intent intent2 = new Intent(getApplicationContext(), Hist.class);
		startActivity(intent2);
	}
	
	public void abresobre(View v){
		Intent intent3 = new Intent(getApplicationContext(), Sobre.class);
		startActivity(intent3);
	}
	
	public void ecraDef(View v){
		Intent intent4 = new Intent(getApplicationContext(), Def.class);
		intent4.putExtra(estruturasLidas, estruturasLer);
		startActivity(intent4);
	}
	
	public void abrirEmail(View v){
		Intent intent5 = new Intent(getApplicationContext(), Email.class);
		startActivity(intent5);
	}
}
